//
//  ProvinceForecastVC.m
//  AirQuality
//
//  Created by Mac on 15/10/5.
//  Copyright © 2015年 Po. All rights reserved.
//

#import "RJProvinceForecastVC.h"
#import "MBProgressHUD+MJ.h"
#import "RJNavBar.h"

@interface RJProvinceForecastVC ()<UIWebViewDelegate>

@property (retain, nonatomic) UIWebView * webView;
@property (strong, nonatomic) NSString *cityName;

- (void)userInterface;

@end

@implementation RJProvinceForecastVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self userInterface];
}

- (void)userInterface{
    
    NSUserDefaults *userDefailt = [NSUserDefaults standardUserDefaults];
    NSArray *userInfo = [userDefailt objectForKey:@"userDefailt1"];
    NSString *url = [[NSString stringWithFormat:@"http://www.scnewair.cn:3389/smartadmin/mobileForecastPro.html"] stringByAppendingString:[NSString stringWithFormat:@"?userName=%@",userInfo[0]]];
    if (![RJUserData defaultRJUserData].isProvince) {
        NSUserDefaults *cityName = [NSUserDefaults standardUserDefaults];
        _cityName = [cityName objectForKey:@"cityName1"];
    }
    NSString *url1 = [url stringByAppendingString:[NSString stringWithFormat:@"?city=%@",_cityName]];
    NSLog(@"%@",url1);
    RJNavBar *navBar = [[RJNavBar alloc] init];
    [navBar getReturnButton];
    navBar.centerCityLabel.text = @"全省预报";
    _webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,50 ,ScreenWidth, ScreenHeight-50)];
    _webView.delegate = self;
    _webView.scalesPageToFit = YES;//自动对页面进行缩放以适应屏幕
    //            _webView.detectsPhoneNumbers = YES;
    //                [_webView loadHTMLString: @"" baseURL: nil];
    [_webView loadRequest:[[NSURLRequest alloc] initWithURL:[NSURL URLWithString:url1]]];
    [self.view addSubview:_webView];
    [self.view addSubview:navBar];
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    [MBProgressHUD showMessage:@"正在加载..."];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [MBProgressHUD hideHUD];
}
@end
